package chap04.Postfix;

/**
 * Created by root on 2017/7/5.
 */
class StackO {
    private int maxSize;
    private Object[] stackArray;
    private int top;

    public StackO(int maxSize) {
        this.maxSize = maxSize;
        stackArray = new Object[maxSize];
        top = -1;
    }

    public void push(Object j) {
        stackArray[++top] = j;
    }

    public Object pop() {
        return stackArray[top--];
    }

    public Object peek() {
        return stackArray[top];
    }

    public boolean isEmpty() {
        return (top == -1);
    }

    public boolean isFull() {
        return (top == maxSize-1);
    }

    public int size() {
        return (top + 1);
    }
}
